<template>
	<view class="content">
		<view class="tag">
			<view class="tag-list">
				<view class="tag-title">{{tag.tag}}</view>
				<view @click="getTagList" :data-tag="tag.tag" class="tag-title">更多</view>
			</view>
			<view class="tag-img">
				<block v-for="(item,index) in list">
					<g-img :list="item"></g-img>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"tag",
		props:['tag'],
		data() {
			return {
				list:null
			};
		},
		beforeCreate() {
			this.$nextTick(() =>{ // 在下一个tick中获取
				const db = uniCloud.database();
				const dbCmd = db.command
				console.log(this.tag.tag,'fenlei')
				db.collection('bz-list').where({
					"img.tag":this.tag.tag
				}).limit(3).get()
				.then(res=>{
					console.log(res.result.data,'jmain')
					this.list = res.result.data
				})
			});
		},
		methods:{
			getTagList(e){
				console.log(e.currentTarget.dataset.tag)
				uni.navigateTo({
					url:'/pages/tag-list/tag-list?tag='+e.currentTarget.dataset.tag
				})
			}
		}
	}
</script>

<style lang="scss">
		.content{
			padding: 15rpx;
			.tag{
				.tag-list{
					padding-inline-start: 10rpx;
					padding-inline-end: 10rpx;
					display: flex;
					justify-content: space-between;
					font-weight: 700;
				}
				.tag-img{
					display: flex;
					justify-content: space-around;
				}
			}
		}
</style>